﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

using LTJ.Config;
using LTJ.Common;

namespace LTJ.Web.UI
{
    /// <summary>
    /// 页面提示页
    /// </summary>
    public class WebMSG
    {
        /// <summary>
        /// 页面错误提示信息
        /// </summary>
        /// <param name="ErrMsg">错误信息</param>
        /// <param name="Url">返回管理员地址  默认可以填写:""或"0"</param>
        /// 更新时间2007-3-7
        static public void ShowError(string ErrMsg, string Url, bool returnUrl)
        {
            PageRender(ErrMsg, Url, false, returnUrl);
        }

        static internal void PageRender(string Msg, string Url, bool Succeed, bool returnUrl)
        {
            GeneralConfigInfo configs = GeneralConfigs.GetConfig();

            string cssDir = configs.Weburl + "css/";
            string STitle = "信息内容成功！";
            string ReUrlStr = "";
            string _tmp = "<img src=\"" + configs.Weburl + "images/icon_right.gif\" border=\"0\">";
            string SCaption = "恭喜！操作成功";
            if (!Succeed)
            {
                STitle = "信息内容错误，请与系统管理员联系！";
                _tmp = "<img src=\"" + configs.Weburl + "images/icon_error.gif\" border=\"0\">";
                SCaption = "<font color=\"red\">抱歉！操作失败</font>";
            }
            System.Web.HttpContext.Current.Response.Clear();
            System.Web.HttpContext.Current.Response.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
            System.Web.HttpContext.Current.Response.Write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\r<head>\r");
            System.Web.HttpContext.Current.Response.Write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
            System.Web.HttpContext.Current.Response.Write("<title>" + STitle + "_cnzshy.com Inc.</title>\r");
            System.Web.HttpContext.Current.Response.Write("<link href=\"" + cssDir + "comm.css\" rel=\"stylesheet\" type=\"text/css\" />\r");
            //System.Web.HttpContext.Current.Response.Write("<script src=\"" + NetCMS.Common.ServerInfo.GetRootURI() + "/configuration/js/Prototype.js\" language=\"javascript\" type=\"text/javascript\"></script>\r");
            //System.Web.HttpContext.Current.Response.Write("<script src=\"" + NetCMS.Common.ServerInfo.GetRootURI() + "/configuration/js/Public.js\" language=\"javascript\" type=\"text/javascript\"></script>\r");
            System.Web.HttpContext.Current.Response.Write("\r</head>\r");
            if (returnUrl)
            {
                if (Url != string.Empty && Url != null)
                {
                    System.Web.HttpContext.Current.Response.Write("<body onload=\"returnPage('" + Url + "');\" style=\"margin-top:50px;\">\r");
                    ReUrlStr = "<li><span style=\"color:blue\">2秒后自动转向...</span></li>";
                }
            }
            else
            {
                System.Web.HttpContext.Current.Response.Write("<body>\r");
            }
            System.Web.HttpContext.Current.Response.Write("<div class=\"cot\">\r");
            System.Web.HttpContext.Current.Response.Write("<div class=\"error\">\r");
            System.Web.HttpContext.Current.Response.Write("<p class=\"tu\">" + _tmp + "</p>\r");
            System.Web.HttpContext.Current.Response.Write("  <div class=\"text\">\r");
            System.Web.HttpContext.Current.Response.Write("    <strong class=\"tit\">" + STitle + "</strong>\r");
            System.Web.HttpContext.Current.Response.Write("    <p class=\"zi1\">" + Msg + "</p>\r");
            System.Web.HttpContext.Current.Response.Write("    <p class=\"zi1\"><a title=\"\" class=\"l_c00\" href=\"javascript:history.back();\">返回上一级</a></p>\r");
            System.Web.HttpContext.Current.Response.Write("  </div>\r");
            System.Web.HttpContext.Current.Response.Write("</div>\r");
            System.Web.HttpContext.Current.Response.Write("</div>\r");
            System.Web.HttpContext.Current.Response.Write("</body>\r");
            System.Web.HttpContext.Current.Response.Write("<script>var intLeft = 2; function returnPage(Url){if (0 == intLeft) top.location.href=Url;else {intLeft -= 1;setTimeout(\"returnPage('\"+Url+\"')\", 2000);}}</script>\r");
            System.Web.HttpContext.Current.Response.Write("</html>\r");
            System.Web.HttpContext.Current.Response.End();
        }
    }
}
